package com.huluobo.a2208parkdemo

import androidx.lifecycle.MutableLiveData
import com.huluobo.base.bean.VideoBean
import com.huluobo.base.mvvm.BaseViewModel
import com.huluobo.base.net.ApiService
import dagger.hilt.android.HiltAndroidApp
import dagger.hilt.android.lifecycle.HiltViewModel
import okhttp3.RequestBody
import javax.inject.Inject

/**
 *  Created by LC on 2024/12/13.
 */
@HiltViewModel
class MainViewModel @Inject constructor(
    val apiService: ApiService
) : BaseViewModel() {
    val getNewsSuccess by lazy { MutableLiveData<String>() }
    fun getNews(body: RequestBody) {
        executeNetwork(
            { apiService.getNews(body) },
            getNewsSuccess::postValue
        )
    }

    val getVideoSuccess by lazy { MutableLiveData<List<VideoBean>>() }
    fun getVideos(currentPage: Int, pageSize: Int) {
        executeNetwork2(
            { apiService.getVideos(currentPage, pageSize) },
            getVideoSuccess::postValue
        )
    }
}